			<script type='text/javascript' charset='utf-8'>
var userid="<?php echo $currentUser->id;?>";
var orgid="<?php echo $organization->id; ?>";
var myRequest=new stackRequest("organization_stack",userid,orgid,new Array());


function addPlan()
{
var num=prompt("请输入计划要添加的产品  "+$('input:radio[name=scan_code]:checked').val()+" 的数量","0");
	if(num!=null){
		if(num!=0&&$.isNumeric(num) ){
			//
			var siblings=$('input:radio[name=scan_code]:checked').parent().siblings();
			
			var para="";
			siblings.each(function(index){
				para+="'"+$(this).text()+"',";
				//console.log($(this).text());
			});
			para="myRequest.add(new iventory("+para+userid+","+orgid+","+num+",0));"
			console.log(para);
			eval(para);
						
				
			//console.log(myRequest.inventorys);
			console.log(myRequest);
		}else{
			alert("输入的数量无效。");
		}
	}
}
function scan(){
	if($('#count_scan').val()!=""){
		var a= myRequest.scan($('#count_scan').val());
		if(a==0){
			alert("此条形码 "+$('#count_scan').val()+"不在入仓盘点表里\n请重新扫描");
		}else if(a==-1){
			alert("此条形码 "+$('#count_scan').val()+"已盘点过的数目已经等于计划数目\n请重新扫描");
		}else{
			//$('#count_scan').focus();
		}
		$('#count_scan').val("");
		$('#count_scan').focus();
	}
}
function stack(){
	var ready=myRequest.isPartiallyReady();
	if(!ready){
		alert("盘点没完成");
	}else{
			jQuery.ajax({
				  type: "POST",
				  url: "api/",
				  dataType : 'json',   
				  data:{	action:"organization_stack",
							userid:myRequest.userid,
							orgid:myRequest.orgid,
							inventorys:myRequest.inventorys},
			  	  beforeSend: function ( xhr ) {
			 		$('.dim').show();
				 	},
				  complete: function(jqXHR) {
				  	   if(jqXHR.readyState != 4) {
				  	   	alert(服务器通讯或者运算出现问题);
				  	   		 $('.dim').hide();
      					 }  
	    			}        
			}).done(function ( data ) {
								 $('.dim').hide();

				if(data['stat']==0){
					alert('递交参数不完整');

				}else{
						myRequest.dump();
					var stackedNum=data['stackedNum'];
					var failededNum=data['failededNum'];
					var error=data['error'];
					var errorName="";
					for (var i = 0; i < error.length; i++) {
						errorName+="\n"+error[i];
					}
					alert("成功入库了"+stackedNum+"种产品,失败了 "+failededNum+"产品。"+errorName);
				}
			});
		
		}
}

function loadTable(){
	
}
$(document).ready(function() {
	
	jQuery.ajax({
				  type: "POST",
				  url: "api/",
				  dataType : 'json',   
				  data:{	action:"organization_stack",
							option:'get_stack',
							orgid:myRequest.orgid},
			  	  beforeSend: function ( xhr ) {
			 		$('.dim').show();
				 	},
				  complete: function(jqXHR) {
				  	   if(jqXHR.readyState != 4) {
				  	   	alert(服务器通讯或者运算出现问题);
				  	   		 $('.dim').hide();
      					 }  
				  	//alert(data['stat']);
				  
 
	    			}        
			}).done(function ( data ) {
				 $('.dim').hide();
				for (var i = 0; i < data.inventorys.length; i++) {
					myRequest.add2(data.inventorys[i]);
				}
									console.log(myRequest);

			});
						//$('#count_scan').focus($('#count_scan').val(""));
					} );
</script>
	<div class="block">

	<div class="invertedshiftdown">
<ul>
	<?php
	if($organization->type=='s'){
	?>
			<li><a href="?page=organization_inventory&id=<?php echo $organization->id; ?>">查看货存</a></li>
			<li><a href="?page=organization_sell&id=<?php echo $organization->id; ?>">出售</a></li>
			<li><a href="?page=organization_return&id=<?php echo $organization->id; ?>">退款</a></li>
			<li><a href="?page=organization_distribute&id=<?php echo $organization->id; ?>">分配</a></li>
			<li><a href="?page=organization_distribute_confirm&id=<?php echo $organization->id; ?>">处理待定分配</a></li>
			<li><a href="?page=organization_transaction&id=<?php echo $organization->id; ?>">查看物流记录</a></li>
			<li><a href="?page=organization_sell_record&id=<?php echo $organization->id; ?>">查看销售记录</a></li>
			<li><a href="?page=organization_consume&id=<?php echo $organization->id; ?>">报告损耗/遗失</a></li>
			<li><a href="?page=organization_count&id=<?php echo $organization->id; ?>">货存盘点</a></li>
	<?php
	}elseif($organization->type=='w'){
	?>
	       	<li><a href="?page=organization_inventory&id=<?php echo $organization->id; ?>">查看库存</a></li>
			<li class="current"><a href="?page=organization_stack&id=<?php echo $organization->id; ?>">入库</a></li>
			<li><a href="?page=organization_distribute&id=<?php echo $organization->id; ?>">分配</a></li>
			<li><a href="?page=organization_distribute_confirm&id=<?php echo $organization->id; ?>">处理待定分配</a></li>
			<li><a href="?page=organization_transaction&id=<?php echo $organization->id; ?>">查看物流记录</a></li>
			<li><a href="?page=organization_consume&id=<?php echo $organization->id; ?>">报告损耗/遗失</a></li>
			<li><a href="?page=organization_count&id=<?php echo $organization->id; ?>">货存盘点</a></li>
    <?php
	}
	?>
</ul>




<form id="myform">
<input type="text" class="textinput" /> <input class="submit" type="submit" value="搜索" />
</form>
</div>

<br style="clear: both;" />
<div id= 'content'>
	<h2><?php echo $organization->name?>》入库</h2>


	
	
	<?php
	if(isset($_GET['stat'])){
		if($_GET['stat']=='stacked'){
			
		
	
	?>
	<div class="isa_success">
		<h4>操作成功：</h4>入库
	</div>
	
	<?php
		}elseif($_GET['stat']=='error'&&$_GET['error']=='notExist'){
	?>
	<div class="isa_warning">
		<h4>操作失败：</h4>无法进行此次入库（选择产品的形码不存在于数据库）
	</div>
	
		<?php
		}elseif($_GET['stat']=='error'&&$_GET['error']=='badData'){
	?>
	<div class="isa_warning">
		<h4>操作失败：</h4>无法入库（提交了无效数据）
	</div>
<?php

		}
}
?>
	<h4>第一步，请从下列“入库盘点表”确定找到你将要入库的货品</h4>
	<div class="important">若在产品表里没有找到相应产品，请让管理员下达入库指令</div>
    	<br>
		<style type='text/css' title='currentStyle'>
					@import 'css/demo_page.css';
					@import 'css/demo_table.css';
				</style>
				<div class='tableBackground'>
				<table cellpadding='0' cellspacing='0' border='0' class='display' id='stackTable' width='100%'>
					<caption style="padding-bottom: 10px"><h2>入库盘点表</h2></caption>
					<thead>
				<tr>
		      	<th>计划入库数量</th>
		      	<th>已扫描数量</th>
				<th>扫描条码</th>
				<th>生产款号</th>
				<th>设计版号</th>
				<th>类型</th>
		        <th>年份</th>
				<th>季节</th>
				<th>流水号</th>
				<th>面料</th>
				<th>色彩</th>
				<th>尺寸</th>
				<th>指令下达日期</th>

				   
				</tr>
			</thead>
			<tbody>
				
			</tbody>
				<tfoot>
				  <tr>
				  	<th>计划入库数量</th>
		      		<th>已盘点数量</th>
					<th>扫描条码</th>
					<th>生产款号</th>
					<th>设计版号</th>
					<th>类型</th>
			        <th>年份</th>
					<th>季节</th>
					<th>流水号</th>
					<th>面料</th>
					<th>色彩</th>
					<th>尺寸</th>
					<th>指令下达日期</th>

				   
				   </tr>
				</tfoot>
			</table>
			</div>	
				<br>
   	<h4>第二步。盘点货物，必须一件件扫描 直到上面盘点表中所有计划入库数目和已扫描数目对齐（红色边框变绿色为止）</h4>

				<div style="padding-left:30%"><input id="count_scan" ype="text" maxlength="14" size="20"><div class="button blue" onclick="scan()">盘点扫描</div></div>
				<br>	
					<div class="important">重复做第二步直到您已经计划好您要做的入库，然后再做第三步--			   	<h4>记得按这个键做入库（否则不算）</h4></div>
			
				<div style="padding-left:40%;padding-right:50%"><img src="images/arrow_down.png"></div>



				<br><div style="padding-left:40%"><button class="button blue" onclick="stack()">盘点完毕入库</div></div>


    </div>
<div class="clear"></div>
	</div>